package com.example.musictutor.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.musictutor.R;
import com.example.musictutor.conf.ImageTextAdapter;

import java.util.ArrayList;

/**
 * Created by ironhulk on 2014/05/09.
 */
public class AboutUsDetailsAdapter extends ArrayAdapter<ImageTextAdapter> {

    private final Context context;
    private final ArrayList<ImageTextAdapter> itemsArrayList;

    public AboutUsDetailsAdapter(Context context, ArrayList<ImageTextAdapter> itemsArrayList){
        super(context,R.layout.about_us_row,itemsArrayList);
        this.context = context;
        this.itemsArrayList = itemsArrayList;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        View rowView = inflater.inflate(R.layout.about_us_row, parent, false);

        ImageView iconImage = (ImageView)rowView.findViewById(R.id.rowIcon);
        TextView rowText = (TextView)rowView.findViewById(R.id.rowText);

        iconImage.setImageResource(itemsArrayList.get(position).getImageId());
        rowText.setText(itemsArrayList.get(position).getTextToDisplay());

        return rowView;
    }

}
